﻿import BiDashboardMenuItem from './BiDashboardMenuItem.vue'
export default {
  components: { BiDashboardMenuItem },
  data () {
    return {
      loading: false,
      formData: null
    }
  },
  created () {
    this.initPage()
  },
  methods: {
    // 初始化页面
    initPage () {
      if (this.$route.query.uid) {
        this.loading = true
        this.getBasicInfoByUid(this.$route.query.uid)
      } else {
        this.$message({
          message: '没有获取到页面信息',
          type: 'error'
        })
      }
    },
    // 获取基础的配置信息
    getBasicInfoByUid (uid) {
      this.$get('/bi_dashboard/detail', {
        id: uid
      }).then(data => {
        let dataResult = data.data.result
        if (dataResult.code === 'success') {
          this.biDashboardInfo = dataResult.data
          if (dataResult.data.settings_json) {
            this.formData = JSON.parse(dataResult.data.settings_json)
          } else {
            this.$message({
              message: '请在仪表板页面进行页面配置',
              type: 'error'
            })
          }
        } else {
          this.$message({
            message: dataResult.msg,
            type: 'warning'
          })
        }
        this.loading = false
      })
    }
  }  
}
